<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <include file="Public:resource"/>
    <title>投诉建议</title>
</head>
<body>
<div class="container">
    <include file="Public:top" title="投诉建议"/>

    <empty name="complaintModel">
        <div class="row" style="margin-top: 30px;">
            <div class="col-xs-12 col-sm-12 col-mg-12 col-md-12" style="font-size: medium;" align="center">
                您没有任何投诉建议
            </div>
        </div>
        <div class="row" style="margin-top: 20px;">
            <div class="col-xs-10 col-sm-10 col-mg-10 col-md-10 col-xs-offset-1 col-sm-offset-1 col-md-offset-1 col-lg-offset-1 m-bn"
                 align="center"
                 onclick="onComplaint()">
                我要投诉建议
            </div>
        </div>
        <else/>

        <div class="row" style="margin-top: 10px;">
            <div class="col-xs-12 col-md-12 col-sm-12 col-lg-12">
                <input type="button" class="btn btn-lg btn-block jss-button"
                       onclick="onComplaint() " value="我要投诉建议"/>
            </div>
        </div>

        <include file="Public:bar" text="我的投诉建议"/>
        <div id="complaint-container">
            <!-- complaint list-->
            <foreach name="complaintModel" item="complaint">
                <div class="row" style="padding-bottom: 5px;border-bottom: darkgray solid 1px;margin-bottom: 10px;">
                    <div class="col-xs-12 col-md-12 col-lg-12 col-sm-12">
                        <div class="row">
                            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                <div class="inline-text">
                                    时间:
                        <span style="color:gray;">
                            {$complaint.usertime}
                        </span>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                <div class="inline-text">
                                    内容:
                        <span style="color:gray;">
                            {$complaint.usercontent}
                        </span>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                <div class="inline-text">
                                    回复:
                        <span style="color:gray;">
                            <empty name="complaint.admincontent">
                                尚未有回复!感谢您的建议.
                                <else/>
                                {$complaint.admincontent}
                            </empty>
                        </span>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-md-12 col-sm-12 col-lg-12">
                                <a href="{:U('Complaint/detail')}&id={$complaint.id}" style="float:right;">查看详情</a>
                            </div>
                        </div>
                    </div>
                </div>
            </foreach>

        </div>

        <div class="row" style="margin: 20px 0px 10px 0px">
            <div class="col-xs-10 col-sm-10 col-md-10 col-lg-10 col-xs-offset-1 col-sm-offset-1 col-md-offset-1 col-lg-offset-1 m-bn"
                 style="background-color: #e1e1e1;font-weight: normal;" align="center" id="load-more"
                 onclick="onLoadMore()">
                加载更多
            </div>
        </div>
    </empty>



    <include file="Public:progress" hint="加载中..."/>
    <include file="Public:message"/>
</div>
<script>
    $(document).ready(function () {
        window.localStorage.setItem("currentComplaintCount", "{$complaintCount}");
    });

    //投诉
    function onComplaint() {
        window.location.href = "{:U('Complaint/addView')}";
    }

    function onLoadMore() {
        showProgress();
        var start = localStorage.getItem('currentComplaintCount');
        var param = {
            start: start
        };
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: "{:U('more')}",
            data: param,
            async :false,
            contentType: "application/x-www-form-urlencoded;charset=utf-8",
            success: function (json) {
                if (json.status == 'success') {
                    //更新显示数量
                    localStorage.setItem('currentComplaintCount', parseInt(start) + json.count);

                    if(json.count == '0'){
                        hideProgress();
                        $("#load-more").html('无更多内容!');
                        $("#load-more").attr("onclick","");
                        return;
                    }
                    $.each(json.complaintModel, function (index, item) {
                        var html = '';
                        html += '<div class="row" style="padding-bottom: 5px;border-bottom: darkgray solid 1px;margin-bottom: 10px;">';
                        html += '	<div class="col-xs-12 col-md-12 col-lg-12 col-sm-12">';
                        html += '		<div class="row">';
                        html += '			<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">';
                        html += '				<div class="inline-text">时间:';
                        html += '			        <span style="color:gray;">';
                        html += '				        '+item.usertime;
                        html += '			        </span>';
                        html += '				</div>';
                        html += '			</div>';
                        html += '		</div>';
                        html += '		<div class="row">';
                        html += '			<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">';
                        html += '				<div class="inline-text">内容:';
                        html += '			        <span style="color:gray;">';
                        html += '			        	'+item.usercontent;
                        html += '		        	</span>';
                        html += '				</div>';
                        html += '			</div>';
                        html += '		</div>';
                        html += '		<div class="row">';
                        html += '			<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">';
                        html += '				<div class="inline-text">回复:';
                        html += '			        <span style="color:gray;">';
                        html += '					    '+item.admincontent;
                        html += '			        </span>';
                        html += '				</div>';
                        html += '			</div>';
                        html += '		</div>';
                        html += '		<div class="row">';
                        html += '			<div class="col-xs-12 col-md-12 col-sm-12 col-lg-12">';
                        html += '				<a href="' + '/WeixinSource/trunk//index.php?m=Home&c=Complaint&a=detail&id=' + item.id + '" style="float:right;">查看详情</a>';
                        html += '			</div>';
                        html += '		</div>';
                        html += '   </div>';
                        html += '</div>';

                        $("#complaint-container").append(html);
                        hideProgress();
                    });
                }
            },
            error: function (msg) {
                hideProgress();
                alert('加载失败,请检查网络!');
            }
        });
    }

</script>
</body>
</html>